<?php
/* @var $this ActivityController */
/* @var $model Activity */

$this->breadcrumbs=array(
	Yii::t('base','Activity')=>array('index'),
	Yii::t('base','Manage'),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#activity-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1><?php echo Yii::t('base','Manage Activity');?></h1>

<?php echo Yii::t('base','<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>');?>

<?php echo CHtml::link(Yii::t('base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php if(yii::app()->user->level() == 9){?>
<a class="btn btn-small create" title="<?php echo Yii::t('base','Create');echo Yii::t('base','Activity');?>" href="<?php echo Yii::app()->request->baseUrl; ?>/activity/create"><?php echo Yii::t('base','Create');echo Yii::t('base','Activity');?></a>
<?php } ?>
<?php if(yii::app()->user->level() == 500){?>
<a class="btn btn-small create" title="<?php echo Yii::t('base','Auto Draw');?>" href="<?php echo Yii::app()->request->baseUrl; ?>/surveyUser/create"><?php echo Yii::t('base','Auto Draw');?></a>

<a class="btn btn-small create" title="<?php echo Yii::t('base','Manually Draw');?>" href="<?php echo Yii::app()->request->baseUrl; ?>/surveyUser/create"><?php echo Yii::t('base','Manually Draw');?></a> 

<?php }?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'activity-grid',
	'dataProvider'=>$model->search(),
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
	'pagerCssClass'=>'pagination',
	'cssFile'=>false,
	'template'=>'{items}{summary}{pager}',
	'columns'=>array(
		//array('name'=>'activity_id'),
		//array('name'=>'classify_id','value'=>'Activity::model()->getActivityClassifyName($data->classify_id)'),
		array('name'=>'user_id','value'=>'DistributionGiftNumber::model()->getPartnersName($data->user_id)'),
		array('name'=>'title'),
		array('name'=>'activity_code'),
		array('name'=>'activity_time'),
		array('name'=>'provide_gift_number'),
		array('name'=>'Used_gift_number'),
		array('name'=>'activity_out_time'),
		//array('name'=>'address1','value'=>'Activity::model()->getAddressListActivity($data->address1,$data->user_id)'),
		array(
			'class'=>'CButtonColumn',
			'header'=>Yii::t('base','Operate'),
			'updateButtonImageUrl'=>array('class'=>'gicon-edit'),
			'updateButtonOptions'=>array('class'=>'btn btn-small'),
			'deleteButtonImageUrl'=>array('class'=>'gicon-edit'),
			'updateButtonUrl'=>'Yii::app()->createUrl("activity/update",array("id"=>$data->activity_id))',
			'deleteButtonUrl'=>'Yii::app()->createUrl("activity/delete",array("id"=>$data->activity_id))',
			'deleteButtonOptions'=>array('class'=>'btn btn-inverse btn-small'),
			'template'=>'{delete}{update}{Auto Draw}{Manually Draw}{Set Address}{Export}',
			'headerHtmlOptions'=>array('style'=>'width:12%'),
			'buttons'=>array(
				'Auto Draw'=>array(
				'label'=>Yii::t('base','Auto Draw'),
				'url'=>'Yii::app()->createUrl("surveyUser/create",array("activity_code"=>$data->activity_code))',
				'options'=>array('class'=>'btn btn-small'),
				'visible'=>'($data->activity_out_time > date("Y-m-d"))',//活动未过期才显示此按钮
				),
				'Manually Draw'=>array(
				'label'=>Yii::t('base','Manually Draw'),
				'url'=>'Yii::app()->createUrl("surveyUser/lottery",array("user_id"=>$data->user_id,"activity_code"=>$data->activity_code))',
				'options'=>array('class'=>'btn btn-small'),
				'visible'=>'($data->activity_out_time > date("Y-m-d"))',//活动未过期才显示此按钮
				),
				'Set Address'=>array(
				'label'=>Yii::t('base','Set Address'),
				'url'=>'Yii::app()->createUrl("activity/setAddress",array("id"=>$data->activity_id))',
				'options'=>array('class'=>'btn btn-small'),
				'visible'=>'(yii::app()->user->level() == 100)',
				),
				'Export'=>array(
						'label'=>Yii::t('base','Export'),
						'url'=>'Yii::app()->createUrl("surveyUser/export",array("activity_code"=>$data->activity_code))',
						'options'=>array('class'=>'btn btn-small'),
				),
			),
			'visible'=>(yii::app()->user->level() == 9||yii::app()->user->level() == 1),
		),
	
	),
)); ?>
